import {Injectable} from '@angular/core';
import * as API from "@api/index";
import {HttpService} from "@core/http/http.service";
import {ToolsService} from "@shared/service/tools/tools.service";

@Injectable()
export class TeacherService {
  // public dataStore = {
  //   // testItemId: 0, // 测试项ID
  //   testItemText: '', // 测试项文本
  //   textItemId: 0
  // };

  constructor(public httpService: HttpService,
              public toolsService: ToolsService) {
  }

  /**
   * @description 查询选择维度
   * @author ouyqx-691
   * @date 2018-4-11
   */
  getTestCategory(params) {
    const url = API.TRAIN_TEACHER_TEST_CATEGORY + "?" + this.toolsService.param(params);
    return this.httpService.get(url).map((res) => res.json());
  }

  /**
   * @description 查询评分标准
   * @author ouyqx-691
   * @date 2018-4-11
   */
  getTestScoreCriteria(params) {
    const url = API.TRAIN_TEST_SCORE_CRITERIA + "?" + this.toolsService.param(params);
    return this.httpService.get(url).map((res) => res.json());
  }

  /**
   * @description 根据测试选项獲取教练班级
   * @author ouyqx-691
   * @date 2018-4-13
   */
  getClassListByTestProjectForTeacher(params) {
    const url = API.TRAIN_TEST_CLASS_LIST + "?" + this.toolsService.param(params);
    return this.httpService.get(url).map((res) => res.json());
  }

  /**
   * @description 根据测试选项獲取教练班级
   * @author ouyqx-691
   * @date 2018-4-13
   */
  getStudentListByClassForTeacher(params) {
    const url = API.TRAIN_TEST_STUDENT_LIST + "?" + this.toolsService.param(params);
    return this.httpService.get(url).map((res) => res.json());
  }

  /**
   * @description 根据测试选项獲取教练班级
   * @author ouyqx-691
   * @date 2018-4-13
   */
  getTestScoreOptionsByStudentForTeacher(params) {
    const url = API.TRAIN_TEST_SCORE_OPTIONS + "?" + this.toolsService.param(params);
    return this.httpService.get(url).map((res) => res.json());
  }

  /**
   * @description 提交测试分数结果
   * @author ouyqx-691
   * @date 2018-4-13
   */
  postStudentTestScore(data) {
    const url = API.TRAIN_TEST_SCORE_POST;
    return this.httpService.postJson(url, data).map((res) => res.json());
  }

  /**
   * @description 根据老师信息查询班级列表
   * @author ouyqx-691
   * @date 2017-12-30
   */
  getClassListForTeacher(params) {
    const url = API.GET_CLASS_LIST_BY_TEACHER_INFO + "?" + this.toolsService.param(params);
    return this.httpService.get(url).map((res) => res.json());
  }

  /**
   * @description 根据班级信息查询学员列表
   * @author ouyqx-691
   * @date 2017-12-31
   */
  getStudentListForTeacher(params) {
    const url = API.GET_STUDENGT_LIST_BY_CLASS_INFO + "?" + this.toolsService.param(params);
    return this.httpService.get(url).map((res) => res.json());
  }

  /**
   * @description 通过学生ID查询学生信息
   * @author ouyqx-691
   * @date 2018-4-16
   */
  getStudentInfoByStudentId(params) {
    const url = API.STUDENT + "?" + this.toolsService.param(params);
    return this.httpService.get(url).map((res) => res.json());
  }

  /**
   * @description 获取学生年龄段分组信息
   * @author ouyqx-691
   * @date 2018-4-16
   */
  getStudentAgeGroup() {
    const url = API.TRAIN_TEST_STUDENT_AGE_GROUNP;
    return this.httpService.get(url).map((res) => res.json());
  }

  /**
   * @description 获取测试项加减分选项
   * @author ouyqx-691
   * @date 2018-4-16
   */
  getTestItemScoreOption(params) {
    const url = API.TREAIN_TEST_SCORE_OPTION + "?" + this.toolsService.param(params);
    return this.httpService.get(url).map((res) => res.json());
  }
}
